package Reminder.domain;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;

public class Period {
    private Course course;
    private int day;
    private int start;
    private boolean isNone = true;
    public Period(int day, int start,JSONObject course) {
        this.course = Course.parseJSON(course);
        this.day = day;
        this.start = start;
        this.isNone = false;
    }
    public Period(){}
    public static Period parseJSON(JSONObject period){
        return new Period(
            period.getInteger("day"),
            period.getInteger("start"),
            JSONObject.parseObject(period.getString("course"))
        );
    }
    public JSONObject toJSON(){
        JSONObject jsonObject = new JSONObject();
        jsonObject.put("day",day);
        jsonObject.put("course",course.toJSON().toString());
        jsonObject.put("start",start);
        return  jsonObject;
    }

    public Course getCourse() {
        return course;
    }

    public void setCourse(Course course) {
        this.course = course;
    }

    public boolean isNone() {
        return isNone;
    }

    public void setNone(boolean none) {
        isNone = none;
    }

    public int getDay() {
        return day;
    }

    public void setDay(int day) {
        this.day = day;
    }

    public int getStart() {
        return start;
    }

    public void setStart(int start) {
        this.start = start;
    }

}
